﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Mysoft.MyCM.Web
{
	public partial class ssoauth : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				try
				{
					M.SSO.AuthVerifyResult result = M.SSO.AuthProvider.GetAuthVerifyResultFromRedirect();
					// 自定义处理
					if (result.VerifyResult)
					{
						// 写入Cookie
						//M.SSO.AuthProvider.SetSSOCookie(
						//	result.User.ToCookieValues(),
						//	M.Web.Util.GetAppConfig("sso-cookie-name"),
						//	M.Web.Util.GetAppConfig("sso-domain"));
						// 写入Session
						Controllers.UserController.SaveLogonUser(result.User);
						Response.Redirect(M.SSO.AuthProvider.GetRedirectUrl());
					}
					else
					{
						Response.Clear();
						Response.Write("单点登陆，验证失败！");
						Response.End();
					}
				}
				catch
				{
					Response.Clear();
					Response.Write("单点登陆，验证失败！");
					Response.End();
				}

			}
		}
	}
}